<template>
  <div class="about">
    <h1>数据测试</h1>
    <button @click="sendRequest">查询infomation的所有信息</button>
    <button @click="sendRequest2">查询infomation的id为1信息</button>
    <button @click="sendRequest3">添加infomation数据</button>
    <button @click="sendRequest4">修改infomation的id为1信息</button>
    <button @click="sendRequest5">删除infomation的id为1信息</button>
  </div>
</template>
<script>
import { get, post, put, del } from "./utils/http";
export default {
  methods: {
    // get查询infomation的所有信息
    async sendRequest() {
      let res = await get("/api/infomation");
      console.log("get查询infomation的所有信息", res);
    },
    // get查询infomation的id为1信息
    async sendRequest2() {
      let res2 = await get("/api/infomation/1");
      console.log("get查询infomation的id为1信息", res2);
    },
    // post添加infomation数据
    async sendRequest3() {
      let res3 = await post("/api/infomation", {
        title: "json-server 的第xxx条数据",
        desc: "奥特曼不想打小怪",
        author: "被奥特曼打了",
      });
      console.log(res3, "post添加infomation数据成功");
    },
    // pust修改infomation的id为1信息
    async sendRequest4() {
      let res4 = await put("/api/infomation/1", {
        title: "json-server 的第x+1条数据",
        desc: "奥特曼想打小怪111",
        author: "2222被奥特曼打了",
      });
      console.log(res4, "pust修改infomation的id为1信息成功");
    },
    // del删除infomation的id为1信息
    async sendRequest5() {
      let res4 = await del("/api/infomation/1");
      console.log(res4, "del删除infomation的id为1信息数据成功");
    },
  },
};
</script>
<style scoped>
button {
  display: block;
}
</style>